package edu.asu.sefcom.crimenet.search.util;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;

import org.apache.log4j.Logger;
import org.neo4j.cypher.ExecutionEngine;
import org.neo4j.cypher.ExecutionResult;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.NotFoundException;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.kernel.EmbeddedGraphDatabase;

import scala.actors.threadpool.Arrays;

public class DBUtils {

	public static void updateUser(Node userN, String propN, Object result,
			GraphDatabaseService graphDB) {
		Transaction tx = graphDB.beginTx();
		try {
			userN.setProperty(propN, result);
			tx.success();
		} catch (Exception e) {
			e.printStackTrace();
			tx.finish();
		} finally {
			tx.finish();
		}
	}

	public static void updateGroup(Node groupN, String propN, Object result,
			GraphDatabaseService graphDB) {
		Transaction tx = graphDB.beginTx();
		try {
			groupN.setProperty(propN, result);
			tx.success();
		} catch (Exception e) {
			e.printStackTrace();
			tx.finish();
		} finally {
			tx.finish();
		}
//		System.out.println(groupN.getProperty("Name")+" : "+propN+" : "+ result);
	}

	public static void printUserInfluence(GraphDatabaseService graphDB) {
		Set<String> uniqueVals = new HashSet<String>();
		for (Node node : DBUtils.getAllNodeTypes(graphDB, "User")) {
			String uName1 = "" + node.getProperty("Name");
			for (String key : node.getPropertyKeys())
				try {
					if (key.matches(CrimenetConstants.USER_INFLUENCE+".*")) {
						String uName = "" + node.getProperty(key);
						if (Double.parseDouble(uName) > 0) {
							uniqueVals.add(uName1 + "-------->" + key + "---->"
									+ Double.parseDouble(uName));
						}
					}
				} catch (Exception e) {
					System.out.println(e.getLocalizedMessage());
				}

		}
		printToFile(null, "" + uniqueVals);
		for (String entr : uniqueVals) {
			printToFile(null, "" + entr);
		}
	}

	public static void printGA(GraphDatabaseService graphDB) {
		Set<String> uniqueVals = new HashSet<String>();
		for (Node node : DBUtils.getAllNodeTypes(graphDB, "Comm")) {
			String uName1 = "" + node.getProperty("Name");
			for (String key : node.getPropertyKeys())
				try {
					if (key.matches(CrimenetConstants.GROUP_ACTIVENESS+".*")) {
						// System.out.println("gotkey" + key);

						String uName = "" + node.getProperty(key);
						if (Double.parseDouble(uName) > 0) {
							uniqueVals.add(uName1 + "-------->" + key + "---->"
									+ Double.parseDouble(uName));
						}
					}
				} catch (Exception e) {
					System.out.println(e.getLocalizedMessage());
				}

		}
		// printToFile(null, "" + uniqueVals);
		for (String entr : uniqueVals) {
			printToFile(null, "" + entr);
		}
	}

	public static void resetGA(GraphDatabaseService graphDB) {
		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		Set<String> usedUsers = new HashSet<String>();

		for (Node node : DBUtils.getAllNodeTypes(graphDB, "Comm")) {
			for (String year1 : yearList) {
				for (String month1 : monthList) {
					String monthyear = month1 + year1;
					DBUtils.updateGroup(node, CrimenetConstants.GROUP_ACTIVENESS+"" + monthyear, "0", graphDB);
				}
			}
		}
	}

	public static void resetUR(GraphDatabaseService graphDB) {
		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		Set<String> usedUsers = new HashSet<String>();

		for (Node node : DBUtils.getAllNodeTypes(graphDB, "User")) {
			for (String year1 : yearList) {
				for (String month1 : monthList) {
					String monthyear = month1 + year1;
					DBUtils.updateGroup(node, CrimenetConstants.USER_RELEVANCE+"" + monthyear, new String[]{}, graphDB);
				}
			}
		}
	}
	public static void printToFile(Node userN, String result) {
		String uName = userN == null ? "" : "" + userN.getProperty("Name");
		Logger.getLogger(DBUtils.class).warn(
				uName + "  " + result);
	}

	public static void printToFileWithName(String fileName, String result) {
		BufferedWriter bw = null;
		try {
			bw = new BufferedWriter(new FileWriter(fileName, true));
			bw.write(result);
			bw.newLine();
		} catch (Exception e) {
			System.out.println(e);
		} finally {
			try {
				bw.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	public static void printGActiveness(GraphDatabaseService graphDB) {
		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		List<String> listReject = Arrays
				.asList(new String[] { "Interests:88: 14/88" });
		boolean check = false;

		Set<String> usedUsers = new HashSet<String>();

		int i = 0;

		for (String year1 : yearList) {
			for (String month1 : monthList) {
				++i;
				String monthyear = month1 + year1;
				Node maxGroup = null;
				List<Node> groups = getAllNodeTypes(graphDB, "Comm");
				double maxGActiv = 0;
				for (Node group : groups) {
					String activeness = "";
					try {
						activeness = "" + group.getProperty(CrimenetConstants.GROUP_ACTIVENESS+"" + monthyear);
					} catch (Exception nfe) {
						activeness = "0";
					}
					double userAct = Double.parseDouble(activeness);
					if (userAct > maxGActiv) {
						String userNam1 = "" + group.getProperty("Name");
						if (usedUsers.add(userNam1)) {
							maxGActiv = userAct;
							maxGroup = group;
							check = listReject.contains(("" + maxGroup
									.getProperty("Name")));
						}
					}
				}
				if (!check) {
					try {
						System.out.println("% " + monthyear + " "
								+ maxGroup.getProperty("Name"));
					} catch (Exception e) {
						if (null != maxGroup) {
							updateUser(maxGroup, CrimenetConstants.GROUP_ACTIVENESS+"" + monthyear, "0", graphDB);
						}
					}
					System.out.print("z(" + ((i - 1) * 48 + 1) + ":" + i * 48
							+ ")=[");

					for (String year2 : yearList) {
						for (String month2 : monthList) {
							try {
								String monthyear2 = month2 + year2;
								String activeness = "";
								try {

									activeness = ""
											+ maxGroup.getProperty(CrimenetConstants.GROUP_ACTIVENESS+""
													+ monthyear2);

								} catch (Exception e) {
									activeness = "0";
								}
								double userAct = Double.parseDouble(activeness);
								System.out.print(userAct + ", ");
							}

							catch (Exception nfe) {
								System.out.println(nfe.getLocalizedMessage());
							}
						}
					}

					System.out.println("];");
				}
			}
		}
	}
	
	public static void printURelevance1(GraphDatabaseService graphDB) {
		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		List<String> listReject = Arrays
				.asList(new String[] { "Interests:88: 14/88" });
		boolean check = false;

		Set<String> usedUsers = new HashSet<String>();

		int i = 0;

		for (String year1 : yearList) {
			for (String month1 : monthList) {
				++i;
				String monthyear = month1 + year1;
				Node maxGroup = null;
				List<Node> groups = getAllNodeTypes(graphDB, "User");
				double maxGActiv = 0;
				for (Node group : groups) {
					String[] activeness = null;
					try {
						activeness = (String[])group.getProperty(CrimenetConstants.USER_RELEVANCE+"" + monthyear);
					} catch (Exception nfe) {
						activeness = new String[]{};
					}
					if(activeness.length==0){
						continue;
					}
					int userAct = 0;
					for(String term:activeness){
						userAct+=Integer.valueOf(term.split("=")[1]);
					}
					if (userAct > maxGActiv) {
						String userNam1 = "" + group.getProperty("Name");
						if (usedUsers.add(userNam1)) {
							maxGActiv = userAct;
							maxGroup = group;
							check = listReject.contains(("" + maxGroup
									.getProperty("Name")));
						}
					}
				}
				if (!check) {
					try {
						System.out.println("% " + monthyear + " "
								+ maxGroup.getProperty("Name"));
					} catch (Exception e) {
						if (null != maxGroup) {
//							updateUser(maxGroup, CrimenetConstants.USER_RELEVANCE+"" + monthyear, "0", graphDB);
						}
					}
					System.out.print("z(" + ((i - 1) * 48 + 1) + ":" + i * 48
							+ ")=[");

					for (String year2 : yearList) {
						for (String month2 : monthList) {
							try {
								String monthyear2 = month2 + year2;
								String[] activeness = null;
								try {

									activeness = (String[])maxGroup.getProperty(CrimenetConstants.USER_RELEVANCE+""
													+ monthyear2);

								} catch (Exception e) {
									activeness = new String[]{};
								}
//								double userAct = Double.parseDouble(activeness);
								if(activeness.length>0)
								System.out.print(Arrays.asList(activeness) + "\n ");
							}

							catch (Exception nfe) {
								System.out.println(nfe.getLocalizedMessage());
							}
						}
					}

					System.out.println("];");
				}
			}
		}
	}
	
	public static void printGInfluence(GraphDatabaseService graphDB) {
		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		List<String> listReject = Arrays
				.asList(new String[] { "Interests:88: 14/88" });
		boolean check = false;

		Set<String> usedUsers = new HashSet<String>();

		int i = 0;

		for (String year1 : yearList) {
			for (String month1 : monthList) {
				++i;
				String monthyear = month1 + year1;
				Node maxGroup = null;
				List<Node> groups = getAllNodeTypes(graphDB, "Comm");
				double maxGActiv = 0;
				for (Node group : groups) {
					String activeness = "";
					try {
						activeness = "" + group.getProperty(CrimenetConstants.GROUP_INFLUENCE+"" + monthyear);
					} catch (Exception nfe) {
						activeness = "0";
					}
					double userAct = Double.parseDouble(activeness);
					if (userAct > maxGActiv) {
						String userNam1 = "" + group.getProperty("Name");
						if (usedUsers.add(userNam1)) {
							maxGActiv = userAct;
							maxGroup = group;
							check = listReject.contains(("" + maxGroup
									.getProperty("Name")));
						}
					}
				}

				// System.out.println(maxUser);
				if (!check) {
					try {
						System.out.println("% " + monthyear + " "
								+ maxGroup.getProperty("Name"));
					} catch (Exception e) {
						if (null != maxGroup) {
							updateUser(maxGroup, CrimenetConstants.GROUP_INFLUENCE+"" + monthyear, "0", graphDB);
						}
					}
					System.out.print("z(" + ((i - 1) * 48 + 1) + ":" + i * 48
							+ ")=[");

					for (String year2 : yearList) {
						for (String month2 : monthList) {
							try {
								String monthyear2 = month2 + year2;
								String activeness = "";
								try {

									activeness = ""
											+ maxGroup.getProperty(CrimenetConstants.GROUP_INFLUENCE+""
													+ monthyear2);
								} catch (Exception e) {
									activeness = "0";
								}
								double userAct = Double.parseDouble(activeness);
								System.out.print(userAct + ", ");
							}
							catch (Exception nfe) {
								System.out.println(nfe.getLocalizedMessage());
							}
						}
					}

					System.out.println("];");
				}
			}
		}

	}
	
	public static void printUActiveness(GraphDatabaseService graphDB) {
		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		int i = 0;

		for (String year1 : yearList) {
			for (String month1 : monthList) {
				++i;
				String monthyear = month1 + year1;
				Node maxUser = null;
				List<Node> users = getAllNodeTypes(graphDB, "User");
				double maxUActiv = 0;
				for (Node user : users) {
					String activeness = "";
					try {
						activeness = "" + user.getProperty(CrimenetConstants.USER_ACTIVENESS+"" + monthyear);
					} catch (Exception nfe) {
						activeness = "0";
					}
					double userAct = Double.parseDouble(activeness);
					if (userAct > maxUActiv) {
						maxUActiv = userAct;
						maxUser = user;
					}
				}
				// System.out.println(maxUser);
				try {
					System.out.println("% " + monthyear + " "
							+ maxUser.getProperty("Name"));
				} catch (Exception e) {
					if (null != maxUser) {
						updateUser(maxUser, CrimenetConstants.USER_ACTIVENESS+"" + monthyear, "0", graphDB);
					}
				}
				System.out.print("z(" + ((i - 1) * 48 + 1) + ":" + i * 48
						+ ")=[");

				for (String year2 : yearList) {
					for (String month2 : monthList) {
						try {
							String monthyear2 = month2 + year2;
							String activeness = "";
							try {

								activeness = ""
										+ maxUser
												.getProperty(CrimenetConstants.USER_ACTIVENESS+"" + monthyear2);

							} catch (Exception e) {
								activeness = "0";
							}
							double userAct = Double.parseDouble(activeness);
							System.out.print(userAct + ", ");
						}

						catch (Exception nfe) {
							System.out.println(nfe.getLocalizedMessage());
						}
					}
				}
				System.out.println("];");
			}
		}

	}



	public static void printUserArticleInfluence(GraphDatabaseService graphDB) {
		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		int i = 0;

		for (String year1 : yearList) {
			for (String month1 : monthList) {
				++i;
				String monthyear = month1 + year1;
				Node maxUser = null;
				List<Node> users = getAllNodeTypes(graphDB, "User");
				double maxUActiv = 0;
				for (Node user : users) {
					String activeness = "";
					try {
						activeness = "" + user.getProperty("" + monthyear);
					} catch (Exception nfe) {
						activeness = "0";
					}
					double userAct = Double.parseDouble(activeness);
					if (userAct > maxUActiv) {
						maxUActiv = userAct;
						maxUser = user;
					}
				}
				// System.out.println(maxUser);
				try {
					System.out.println("% " + monthyear + " "
							+ maxUser.getProperty("Name"));
				} catch (Exception e) {
					if (null != maxUser) {
						updateUser(maxUser, "" + monthyear, "0", graphDB);
					}
				}
				System.out.print("z(" + ((i - 1) * 48 + 1) + ":" + i * 48
						+ ")=[");

				for (String year2 : yearList) {
					for (String month2 : monthList) {
						try {
							String monthyear2 = month2 + year2;
							String activeness = "";
							try {

								activeness = ""
										+ maxUser
												.getProperty("" + monthyear2);

							} catch (Exception e) {
								activeness = "0";
							}
							double userAct = Double.parseDouble(activeness);
							System.out.print(userAct + ", ");
						}

						catch (Exception nfe) {
							System.out.println(nfe.getLocalizedMessage());
						}
					}
				}
				System.out.println("];");
			}
		}

	}
	public static List<String> printURelevance(GraphDatabaseService graphDB) {
		List<String> returnList=new LinkedList<String>();
		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		int i = 0;

		for (String year1 : yearList) {
			for (String month1 : monthList) {
				++i;
				String monthyear = month1 + year1;
				Node maxUser = null;
				List<Node> users = getAllNodeTypes(graphDB, "User");
				double maxUActiv = 0;
				for (Node user : users) {
					String[] activeness = null;
					try {
//this is unlike user influence wher the article influence is stored for user as just monthyear
						activeness = (String[])user.getProperty(""+CrimenetConstants.USER_RELEVANCE + monthyear);
						if(activeness.length>0){
							if(activeness[0].equalsIgnoreCase("1")){
								updateUser(user,""+CrimenetConstants.USER_RELEVANCE + monthyear,new String[]{},graphDB);
							}else{
						Logger.getLogger(DBUtils.class).error(""+CrimenetConstants.USER_RELEVANCE + monthyear+" : "+user.getProperty("Name")+" : "+Arrays.asList(activeness));
						returnList.add(monthyear+" "+user.getProperty("Name")+" :$: "+Arrays.asList(activeness));
							}
						}
					} catch (Exception e) {
//						System.out.println(e);
					}
				}
			}
		}
	return returnList;
	}
	
	public static void printUInfluence(GraphDatabaseService graphDB) {

		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		Set<String> usedUsers = new HashSet<String>();

		int i = 0;

		for (String year1 : yearList) {
			for (String month1 : monthList) {
				++i;
				String monthyear = month1 + year1;
				Node maxUser = null;
				List<Node> users = getAllNodeTypes(graphDB, "User");
				double maxUActiv = 0;
				for (Node user : users) {
					String activeness = "";
					try {
						activeness = "" + user.getProperty(CrimenetConstants.USER_INFLUENCE + monthyear);
					} catch (Exception nfe) {
						activeness = "0";
					}
					double userAct = Double.parseDouble(activeness);

					if (userAct > maxUActiv) {
						String userNam1 = "" + user.getProperty("Name");
						if (usedUsers.add(userNam1)) {
							maxUActiv = userAct;
							maxUser = user;
						}
					}
				}
				try {
					System.out.println("% " + monthyear + " "
							+ maxUser.getProperty("Name"));
				} catch (Exception e) {
					if (null != maxUser) {
//						updateUser(maxUser, CrimenetConstants.USER_INFLUENCE + monthyear, "0", graphDB);
					}
				}
				System.out.print("y(" + ((i - 1) * 48 + 1) + ":" + i * 48
						+ ")=[");

				for (String year2 : yearList) {
					for (String month2 : monthList) {
						try {
							String monthyear2 = month2 + year2;
							String activeness = "";
							try {

								activeness = ""
										+ maxUser
												.getProperty(CrimenetConstants.USER_INFLUENCE + monthyear2);

							} catch (Exception e) {
								activeness = "0";
							}
							double userAct = Double.parseDouble(activeness);
							System.out.print(userAct + ", ");
						}

						catch (Exception nfe) {
							System.out.println(nfe.getLocalizedMessage());
						}
					}
				}

				System.out.println("];");
			}
		}

	}

	public static void printUInfluence1(GraphDatabaseService graphDB) {

		List<String> userList = Arrays.asList(new String[] { "kyprizel",
				"arkanoid,_moreno_", "misha", "_zen_it", "sww_", "cuttah",
				"yenpox", "smixok", "countdown_ua", "andybeg", "enkryptor",
				"piska", "mor_phia", "da99er", "countdown_ua", "chaotist",
				"1983_ss", "fluro_iv", "pedestrian_t", "stden" });

		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		for (String userName : userList) {
			for (String year1 : yearList) {
				for (String month1 : monthList) {
					String monthyear = month1 + year1;
					Node user = getNodeByName(graphDB, userName, "User");
					String infl = "";
					String act = "";
					try {
						infl = "" + user.getProperty(CrimenetConstants.USER_INFLUENCE + monthyear);
					} catch (Exception nfe) {
						infl = "0";
					}
					try {
						act = "" + user.getProperty(CrimenetConstants.USER_ACTIVENESS+"" + monthyear);
					} catch (Exception nfe) {
						act = "0";
					}

					printToFileWithName("UICoef.txt", infl + " ");
					printToFileWithName(CrimenetConstants.USER_ACTIVENESS+"Coef.txt", act + " ");
				}
			}
		}

	}

	public static void printGInfluence1(GraphDatabaseService graphDB) {

//		List<String> userList = Arrays.asList(new String[] { "_sleeplessness_",
//				"by_maskva", "art_by_girls", "allvir2al", "ai_ru", "69_ru",
//				"f_i_s_h_k_a", "alxmcr", "mirandolinaspb", "lexadottem97org",
//				"bhcrew", "damagelab", "CUP", "murmansk", "ru_im_logs",
//				"by_maskva", "advancedcpp", "bad_girlzzz", "blackcats",
//				"art_apocalypse" });

		List<String> monthList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		List<String> yearList = Util.getYearList();

		for (Node user1 : DBUtils.getAllNodeTypes(graphDB, "Group")) {
			String userName=""+user1.getProperty("Name");
			for (String year1 : yearList) {
				for (String month1 : monthList) {
					String monthyear = month1 + year1;
					Node user = getNodeByName(graphDB, userName, "Comm");
					String infl = "";
					String act = "";
					try {
						infl = "" + user.getProperty(CrimenetConstants.GROUP_INFLUENCE+"" + monthyear);
					} catch (Exception nfe) {
						infl = "0";
					}
					try {
						act = "" + user.getProperty(CrimenetConstants.GROUP_ACTIVENESS+"" + monthyear);
					} catch (Exception nfe) {
						act = "0";
					}

					
					printToFileWithName(CrimenetConstants.GROUP_INFLUENCE+"Coef.txt", infl + " ");
					printToFileWithName(CrimenetConstants.GROUP_ACTIVENESS+"Coef.txt", act + " ");
				}
			}
		}

	}

	// public static void calcUInfluence(GraphDatabaseService graphDB) {
	// List<String> monthList = Arrays.asList(new String[] { "January",
	// "February", "March", "April", "May", "June", "July", "August",
	// "September", "October", "November", "December" });
	//
	// List<String> yearList = Util.getYearList();,
	// "2007", "2008" });
	//
	// int i = 0;
	//
	// for (String year1 : yearList) {
	// for (String month1 : monthList) {
	// ++i;
	// String monthyear = month1 + year1;
	// Node maxUser = null;
	// List<Node> users = getAllNodeTypes(graphDB, "User");
	// double maxUActiv = 0;
	// for (Node user : users) {
	// String activeness = "";
	// try {
	// activeness = ""
	// + user.getProperty(CrimenetConstants.USER_INFLUENCE + monthyear);
	// }
	// catch (Exception nfe) {
	// activeness="0";
	// }
	// double userAct = Double.parseDouble(activeness);
	// if(userAct > maxUActiv){
	// maxUActiv = userAct;
	// maxUser = user;
	// }
	// }
	// // System.out.println(maxUser);
	// try {
	// System.out.println("% " + monthyear + " "
	// + maxUser.getProperty("Name"));
	// } catch (Exception e) {
	// if(null!=maxUser){
	// updateUser(maxUser, CrimenetConstants.USER_INFLUENCE + monthyear, "0", graphDB);
	// }
	// }
	// System.out.print("y(" + ((i - 1) * 48 + 1) + ":" + i * 48
	// + ")=[");
	//
	// for (String year2 : yearList) {
	// for (String month2 : monthList) {
	// try {
	// String monthyear2 = month2 + year2;
	// String activeness = "";
	// try {
	//
	// activeness = ""+ maxUser.getProperty(CrimenetConstants.USER_INFLUENCE + monthyear2);
	//
	// } catch (Exception e) {
	// activeness="0";
	// }
	// double userAct = Double.parseDouble(activeness);
	// System.out.print(userAct + ", ");
	// }
	//
	// catch (Exception nfe) {
	// System.out.println(nfe.getLocalizedMessage());
	// }
	// }
	// }
	//
	// System.out.println("];");
	// }
	// }
	//
	// }
	public static int getNumUsersForRel(Node userN, CrimenetRelationshipTypes reType,
			String nodeType) {
		int totalFollows = 0;
		for (Relationship relationship : userN.getRelationships()) {
			if (("" + relationship.getType()).equals("" + reType)) {
				Relationship postsrel = relationship;
				totalFollows = printCountForRel(userN, postsrel, nodeType);
			}
		}
		return totalFollows;
	}

	public static Map<String, Node> getUsersInGroup(Node groupNode) {
		Map<String, Node> usersInGrMap = new HashMap<String, Node>();
		for (Relationship relationship : groupNode.getRelationships()) {
			if (("" + relationship.getType()).equals(""
					+ CrimenetRelationshipTypes.Follows)) {
				Node user = relationship.getEndNode();
				String uName = "" + user.getProperty("Name");
				usersInGrMap.put(uName, user);
			}
		}
		return usersInGrMap;
	}

	public static int getNumGroupsForRel(Node userN,
			CrimenetRelationshipTypes reType, String nodeType) {
		int totalFollows = 0;
		for (Relationship relationship : userN.getRelationships()) {
			if (("" + relationship.getType()).equals("" + reType)) {
				Relationship postsrel = relationship;
				totalFollows = printCountForRel(userN, postsrel, nodeType);
			}
		}
		return totalFollows;
	}

	public static int printCountForRel(Node userN, Relationship rel,
			String nodeType) {
		int followsCount = 0;
		for (Node user : rel.getNodes()) {
			for (String userProperty : user.getPropertyKeys()) {

				if ((userProperty).equals("Type")) {
					try {
						if (user.getProperty(userProperty).equals(nodeType)) {
							followsCount++;
						}
					} catch (NotFoundException nfe) {
						System.out.println(nfe.getLocalizedMessage());
					}

				}
			}
		}
		return followsCount;
	}

	public static List<Node> getAllNodeTypes(GraphDatabaseService graphDB12,
			String type) {

		// Transaction tx = graphDB12.beginTx();
		List<Node> userNameSet = new ArrayList<Node>();
		// try {
		Iterable<Node> itr = graphDB12.getAllNodes();
		for (Node user : itr) {
			for (String userProperty : user.getPropertyKeys()) {

				if ((userProperty).equals("Type")) {
					if (user.getProperty(userProperty).equals(type)) {
						userNameSet.add(user);
					}

				}
			}
		}
		// tx.success();
		// } finally {
		// tx.finish();
		// }

		return userNameSet;
	}

	private static void printPerMonthArtUser(GraphDatabaseService graphDB,
			Node userN, Relationship postsrel) {
		SimpleDateFormat sdf = new SimpleDateFormat(
				"EEE MMM dd HH:mm:ss z yyyy");
		SimpleDateFormat sdf2 = new SimpleDateFormat("MM");
		SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy");

		List<String> completeList = Arrays.asList(new String[] { "January",
				"February", "March", "April", "May", "June", "July", "August",
				"September", "October", "November", "December" });

		String uName = "" + userN.getProperty("Name");
		int monthcount = 0;
		Transaction tx = graphDB.beginTx();
		try {
			Iterable<Node> itr = Arrays.asList(postsrel.getNodes());
			for (Node ar : itr) {
				for (String userProperty : ar.getPropertyKeys()) {

					if ((userProperty).equals("Type")) {
						if (ar.getProperty(userProperty).equals("Article")) {
							try {

								Date d = sdf.parse((String) ar
										.getProperty("Date"));
								int monthNumber = Integer.parseInt(sdf2
										.format(d));
								int year = Integer.parseInt(sdf3.format(d));

								String monthName = completeList
										.get(monthNumber - 1);
								String monthyear = monthName + year;
								// Integer count =
								// follarticleCount.get(monthyear) == null ? 0
								// : follarticleCount.get(monthyear);
								// follarticleCount.put(monthyear, ++count);
								// tx.finish();
								// Integer count1 =
								// follarticleCount.get(monthyear) == null ? 0
								// : follarticleCount.get(monthyear);
								// System.out.println(count);
							} catch (Exception e) {
								System.out.println(e);
							}
						}
					}
				}
			}
			tx.success();
		} finally {
			tx.finish();
		}
		//
		// for (String follUser : follarticleCount.keySet()) {
		// // Logger.getLogger(UserParserTemplate.class).warn(
		// // "monthy " + follUser + " count "
		// // + follarticleCount.get(follUser));
		// System.out.println("monthy " + follUser + " count "
		// + follarticleCount.get(follUser));
		// }
	}

	private static void printUserInfo(GraphDatabaseService graphDB) {

		Transaction tx = graphDB.beginTx();
		Set<String> typeSet = new HashSet<String>();
		try {
			Iterable<Node> itr = graphDB.getAllNodes();
			for (Node user : itr) {
				long id = user.getId();
				// if(id==8112){
				for (String userProperty : user.getPropertyKeys()) {

					if ((userProperty).equals("Text")) {
						// typeSet.add(""+user.getProperty(userProperty));
						// typeSet.add(userProperty);

						typeSet.add("" + id);
					}
				}
				// }
				for (Relationship rel : user.getRelationships()) {

					Node n1 = rel.getStartNode();
					Node n2 = rel.getEndNode();
					// if ((userProperty).equals("Text")) {
					// typeSet.add(""+user.getProperty(userProperty));
					// typeSet.add(userProperty);
					try {
						System.out.println(n1.getProperty("Type"));
						System.out.println(n2.getProperty("AII"));
						printNodePropNames(graphDB, n2.getId(), null);
						System.out.println("type :   " + rel.getType());
						// UserInfluenceCalculator.printCountForRel(user,rel,"User");
						printNodePropNames(graphDB, n1.getId(), "User");
					} catch (NotFoundException e) {
					}
					// typeSet.add(""+id);
					// }
				}
			}
			tx.success();
		} finally {
			tx.finish();
		}
		// System.out.println(typeSet);
		System.out.println(typeSet.size());

		// Logger.getLogger(DBUtils.class).warn(
		// "printArticleNumGroups res: " + sm);
	}

	public static void printUserPropNames(GraphDatabaseService graphDB) {
		List<Node> users = DBUtils.getAllNodeTypes(graphDB, "User");
		Set<String> propSet = new HashSet<String>();
		for (Node user1 : users) {
			for (String userProperty1 : user1.getPropertyKeys()) {
				propSet.add(userProperty1);
			}
		}
		System.out.println(propSet);
	}

	public static void printNodePropNames(GraphDatabaseService graphDB,
			long id, String nodetype) {
		Iterable<Node> users = null;
		if (null == nodetype) {
			users = graphDB.getAllNodes();
		} else {
			users = DBUtils.getAllNodeTypes(graphDB, nodetype);
		}
		Set<String> propSet = new HashSet<String>();
		for (Node user1 : users) {
			if (user1.getId() == id) {
				for (String userProperty1 : user1.getPropertyKeys()) {
					propSet.add(userProperty1);
				}
			}
		}
		System.out.println(propSet);
	}

	private static void printArticlesMax(GraphDatabaseService graphDB) {

		Map<String, Integer> sm = new HashMap<String, Integer>();
		Transaction tx = graphDB.beginTx();
		int userCnt = 0;
		try {
			List<Node> users = DBUtils.getAllNodeTypes(graphDB, "User");
			for (Node user : users) {
				int articleCount = 0;
				for (Relationship rel : user.getRelationships()) {
					if (("" + rel.getType()).equals(""
							+ CrimenetRelationshipTypes.Posts)) {
						for (Node user1 : rel.getNodes()) {
							for (String userProperty1 : user1.getPropertyKeys()) {

								if ((userProperty1).equals("Type")) {

									if (user1.getProperty(userProperty1)
											.equals("Article")) {
										articleCount++;

									}
								}
							}
						}
					}
				}
				String uName = "" + user.getProperty("Name");
				sm.put(uName, articleCount);
			}
			// String userN=""+user.getProperty("Name");
			// sm.put(userN, arCnt);
			int count = 0;
			String maxUser = "";
			for (String name1 : sm.keySet()) {
				if (sm.get(name1) > count) {
					count = sm.get(name1);
					maxUser = name1;
				}
			}
			System.out.println(maxUser + "  " + count);

			tx.success();
		} finally {
			tx.finish();
		}
		Logger.getLogger(DBUtils.class).warn(
				"printArticleNumGroups res: " + sm);
	}

	private static void printArticleNumGroups(GraphDatabaseService graphDB) {
		Map<String, Integer> sm = new HashMap<String, Integer>();
		Transaction tx = graphDB.beginTx();
		int userCnt = 0;
		try {
			Iterable<Node> itr = graphDB.getAllNodes();
			for (Node user : itr) {
				for (String userProperty : user.getPropertyKeys()) {

					if ((userProperty).equals("Type")) {

						if (user.getProperty(userProperty).equals("Comm")) {

							String groupNa = "" + user.getProperty("Name");
							if (checkForGrName(groupNa)) {
								int arCnt = 0;
								for (Relationship rel : user.getRelationships()) {
									// Logger.getLogger(Testing.class).warn(
									// "type" + rel.getType());
									if (("" + rel.getType()).equals(""
											+ CrimenetRelationshipTypes.MemberOf)) {
										int userarCnt = printUsersForRel(rel);
										arCnt = arCnt + userarCnt;
										userCnt++;
									}
								}
								System.out.println(groupNa + "------users----"
										+ userCnt + "--------artcount---------"
										+ arCnt);
							}
							// String userN=""+user.getProperty("Name");
							// sm.put(userN, arCnt);
						}

					}
				}
			}
			tx.success();
		} finally {
			tx.finish();
		}
		Logger.getLogger(DBUtils.class).warn(
				"printArticleNumGroups res: " + sm);
	}

	private static boolean checkForGrName(String groupNa) {
		String[] arr = new String[] { "hellknights", "ru_hack", "mazafaka",
				"CUP", "damagelab", "bhcrew" };
		List<String> list = Arrays.asList(arr);
		return list.contains(groupNa) ? true : false;
	}

	private static int printUsersForRel(Relationship rel) {
		int totalCnt = 0;
		for (Node n1 : rel.getNodes()) {
			for (String userProperty : n1.getPropertyKeys()) {

				if ((userProperty).equals("Type")) {
					if (n1.getProperty(userProperty).equals("User")) {
						for (Relationship relationship : n1.getRelationships()) {
							if (("" + relationship.getType()).equals(""
									+ CrimenetRelationshipTypes.Posts)) {
								Relationship postsrel = relationship;
								int arcount = printArticlesForRel(n1, postsrel);
								totalCnt = totalCnt + arcount;
							}
						}
					}
				}
			}
		}
		return totalCnt;
	}

	private static int printArticlesForRel(Node parent, Relationship postsrel) {
		int artCount = 0;
		for (Node user : postsrel.getNodes()) {
			for (String userProperty : user.getPropertyKeys()) {

				if ((userProperty).equals("Type")) {
					// System.out.println(user.getProperty(userProperty));
					try {
						if (user.getProperty(userProperty).equals("User")) {
							artCount++;
							String nam1 = "" + parent.getProperty("Name");
							String Translated1 = "";// +user.getProperty("Translated");

							// Logger.getLogger(Testing.class).warn(nam1+
							// "----------" + Translated1);
							// printPostRelation(user);
						}
					} catch (NotFoundException nfe) {
						System.out.println(nfe.getLocalizedMessage());
					}

				}
			}
		}

		return artCount;

	}

	private static void printPostRelation(Node n1) {
		for (Relationship relationship : n1.getRelationships()) {
			if (("" + relationship.getType()).equals(""
					+ CrimenetRelationshipTypes.Posts)) {
				Relationship postsrel = relationship;
				for (Node user : postsrel.getNodes()) {
					for (String userProperty : user.getPropertyKeys()) {

						if ((userProperty).equals("Type")) {
							// System.out.println(user.getProperty(userProperty));
							try {
								if (user.getProperty(userProperty).equals(
										"User")) {
									String nam1 = "" + n1.getProperty("Name");
									String Translated1 = "";// +user.getProperty("Translated");

									// Logger.getLogger(Testing.class).warn(nam1+
									// "----------" + Translated1);
									// return;
								}
							} catch (NotFoundException nfe) {
								System.out.println(nfe.getLocalizedMessage());
							}

						}
					}
				}
			}
		}
	}

	private static void printLocationUsers(GraphDatabaseService graphDB) {
		Map<String, Integer> localitycount = new HashMap<String, Integer>();
		Map<String, Integer> regcount = new HashMap<String, Integer>();
		Map<String, Integer> cntcount = new HashMap<String, Integer>();
		Transaction tx = graphDB.beginTx();
		try {
			Iterable<Node> itr = graphDB.getAllNodes();
			for (Node user : itr) {
				for (String userProperty : user.getPropertyKeys()) {

					if ((userProperty).equals("Type")) {
						if (user.getProperty(userProperty).equals("User")) {
							try {
								String loc = "" + user.getProperty("Location2");// "Locality"Location2
								countLoc(localitycount, loc);
							} catch (NotFoundException n) {
								System.out.println(n.getLocalizedMessage());
							}
							try {
								String reg = "" + user.getProperty("Region");// "Locality"Location2
								countLoc(regcount, reg);

							} catch (NotFoundException n) {
								System.out.println(n.getLocalizedMessage());
							}
							try {
								String cn = "" + user.getProperty("Country");// "Locality"Location2
								countLoc(cntcount, cn);
							} catch (NotFoundException n) {
								System.out.println(n.getLocalizedMessage());
							}

						}
					}
				}
			}
			tx.success();
		} finally {
			tx.finish();
		}
		System.out.println(localitycount);
		System.out.println(regcount);
		System.out.println(cntcount);
		// Region", engRegion);
		// userNode.setProperty("Country"

	}

	private static void countLoc(Map<String, Integer> map1, String loc) {
		if (!map1.containsKey(loc)) {
			map1.put(loc, 1);
		} else {
			Integer cnt = map1.get(loc);
			map1.put(loc, ++cnt);
		}
	}

	private static void printNumUsersGroup(GraphDatabaseService graphDB) {
		List<String> list1 = new ArrayList<String>();
		Transaction tx = graphDB.beginTx();
		SortedMap<Integer, String> sm = new TreeMap<Integer, String>();
		try {
			Iterable<Node> itr = graphDB.getAllNodes();
			for (Node user : itr) {
				for (String userProperty : user.getPropertyKeys()) {

					if ((userProperty).equals("Type")) {
						if (user.getProperty(userProperty).equals("Comm")) {
							int usergroup = 0;
							for (Relationship rel : user.getRelationships()) {
								Logger.getLogger(DBUtils.class).warn(
										"type" + rel.getType());
								if (("" + rel.getType()).equals(""
										+ CrimenetRelationshipTypes.MemberOf)) {
									Logger.getLogger(DBUtils.class).warn(
											"type");
									usergroup++;
								}
							}
							String p = "group : " + user.getProperty("Name")
									+ " no of users:" + usergroup;
							Logger.getLogger(DBUtils.class).warn(p);
							if (sm.containsKey(usergroup)) {
								String val = sm.get(usergroup);
								sm.put(usergroup, val + "$$"
										+ user.getProperty("Name"));
							} else {
								sm
										.put(usergroup, ""
												+ user.getProperty("Name"));
							}
							// list1.add(p);
						}

					}
				}
			}
			tx.success();
		} finally {
			tx.finish();
		}
		Logger.getLogger(DBUtils.class).warn(sm);
	}

	private static void printNumArticlesMonth(GraphDatabaseService graphDB) {
		int excount = 0;
		Map<String, Integer> monthcount = new HashMap<String, Integer>();
		Transaction tx = graphDB.beginTx();
		try {
			Iterable<Node> itr = graphDB.getAllNodes();
			for (Node user : itr) {
				for (String userProperty : user.getPropertyKeys()) {

					if ((userProperty).equals("Type")) {
						if (user.getProperty(userProperty).equals("Article")) {
							SimpleDateFormat sdf = new SimpleDateFormat(
									"EEE MMM dd HH:mm:ss z yyyy");
							SimpleDateFormat sdf2 = new SimpleDateFormat("MM");
							SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy");

							try {
								Date d = sdf.parse((String) user
										.getProperty("Date"));
								// System.out.println("Date ## :"+d.toString());
								// System.out.println("Month " +
								// sdf2.format(d));
								int month = Integer.parseInt(sdf2.format(d));
								int year = Integer.parseInt(sdf3.format(d));
								switch (year) {
								case 2006:
									String key = "2006/" + month;
									updateMC(monthcount, key);
									break;
								case 2007:
									String key1 = "2007/" + month;
									updateMC(monthcount, key1);
									break;
								case 2008:
									String key2 = "2008/" + month;
									updateMC(monthcount, key2);
									break;
								default:
									System.out.println("indefault " + year
											+ "/" + month);
									break;
								}
							} catch (Exception e) {
								e.printStackTrace();
								excount++;
							}
						}
					}
				}
			}
			tx.success();
		} finally {
			tx.finish();
		}
		System.out.println(monthcount);
		System.out.println(excount);
	}

	private static void updateMC(Map<String, Integer> monthcount, String key) {
		if (monthcount.containsKey(key)) {
			Integer cnt = monthcount.get(key);
			monthcount.put(key, ++cnt);
		} else {
			monthcount.put(key, 1);
		}
	}

	private static void printBirthDates(GraphDatabaseService graphDB) {
		int artCount = 0;
		Transaction tx = graphDB.beginTx();
		Set<String> bdSet = new HashSet<String>();
		try {
			Iterable<Node> itr = graphDB.getAllNodes();
			for (Node user : itr) {
				for (String userProperty : user.getPropertyKeys()) {

					if ((userProperty).equals("Type")) {
						if (user.getProperty(userProperty).equals("User")) {
							try {
								String bdate = ""
										+ user.getProperty("birthDate");
								bdSet.add(bdate);
								Logger.getLogger(DBUtils.class).warn(bdate);
							} catch (NotFoundException n) {
								System.out.println(n.getLocalizedMessage());
							}
						}

					}
				}
			}
			tx.success();
		} finally {
			tx.finish();
		}
		Logger.getLogger(DBUtils.class).warn(
				"end of bdate search result: " + bdSet);
	}

	public static void printGroups(GraphDatabaseService graphDB) {
		int artCount = 0;
		Transaction tx = graphDB.beginTx();
		Set<String> userNameSet = new HashSet<String>();
		try {
			Iterable<Node> itr = graphDB.getAllNodes();
			for (Node user : itr) {
				for (String userProperty : user.getPropertyKeys()) {

					if ((userProperty).equals("Type")) {
						if (user.getProperty(userProperty).equals("Comm")) {

							artCount++;
						}

					}
				}
			}
			tx.success();
		} finally {
			tx.finish();
		}
		System.out.println("no of groups:" + artCount);

	}

	// private static void printGroupArticles(GraphDatabaseService graphDB) {
	// int artCount = 0;
	// Transaction tx = graphDB.beginTx();
	// Set<String> userNameSet = new HashSet<String>();
	// try {
	// Iterable<Node> itr = graphDB.getAllNodes();
	// for (Node user : itr) {
	// for (String userProperty : user.getPropertyKeys()) {
	//
	// if ((userProperty).equals("Type")) {
	// if (user.getProperty(userProperty).equals("Comm")) {
	// String groupNa=""+user.getProperty("Name");
	// if(checkForGrName(groupNa)){
	//
	// printUsersForRel(
	// }
	// }
	//
	// }
	// }
	// }
	// tx.success();
	// } finally {
	// tx.finish();
	// }
	// System.out.println("no of groups:" + artCount);
	//
	// }
	private static void printArticles(GraphDatabaseService graphDB) {
		int artCount = 0;
		Transaction tx = graphDB.beginTx();
		Set<String> userNameSet = new HashSet<String>();
		try {
			Iterable<Node> itr = graphDB.getAllNodes();
			for (Node user : itr) {
				for (String userProperty : user.getPropertyKeys()) {

					if ((userProperty).equals("Type")) {
						if (user.getProperty(userProperty).equals("Article")) {
							artCount++;
						}

					}
				}
			}
			tx.success();
		} finally {
			tx.finish();
		}
		System.out.println("no of articles:" + artCount);

	}

	private static void printUsers(GraphDatabaseService graphDB) {
		int userCount = 0;
		Transaction tx = graphDB.beginTx();
		Set<String> userNameSet = new HashSet<String>();
		try {
			Iterable<Node> itr = graphDB.getAllNodes();
			for (Node user : itr) {
				for (String userProperty : user.getPropertyKeys()) {

					if ((userProperty).equals("Type")) {
						if (user.getProperty(userProperty).equals("User")) {
							String n1 = "" + user.getProperty("Name");
							int v = userNameSet.add(n1) ? userCount++ : 0;
						}

					}
				}
			}
			tx.success();
		} finally {
			tx.finish();
		}
		System.out.println("no of users:" + userCount);

	}

	public static Node getNodeByName(GraphDatabaseService graphDB, String name,
			String type) {
		Node returnU = null;
		// Transaction tx = graphDB.beginTx();
		// try {
		Iterable<Node> itr = graphDB.getAllNodes();
		boolean found = false;
		for (Node user : itr) {
			for (String userProperty : user.getPropertyKeys()) {
				if ((userProperty).equals("Type")) {
					if (user.getProperty(userProperty).equals(type)) {
						String uName = "" + user.getProperty("Name");
						if (uName.equalsIgnoreCase(name)) {
							returnU = user;
							found = true;
							break;

						}
					}
				}

			}
			if (found) {
				break;
			}
		}
		// tx.success();
		// } finally {
		// tx.finish();
		// }
		return returnU;

	}

	public static List<Node> getAllNodesInRel(Node groupN,
			CrimenetRelationshipTypes memberof, String nodeType) {

		List<Node> nodes = new ArrayList<Node>();
		for (Relationship relationship : groupN.getRelationships()) {
			if (("" + relationship.getType()).equals("" + memberof)) {
				for (Node user : relationship.getNodes()) {
					for (String userProperty : user.getPropertyKeys()) {

						if ((userProperty).equals("Type")) {
							try {
								if (user.getProperty(userProperty).equals(
										nodeType)) {
									nodes.add(user);
								}
							} catch (NotFoundException nfe) {
								System.out.println(nfe.getLocalizedMessage());
							}
						}
					}
				}
			}
		}
		return nodes;
	}

	public static Iterable<Node> getAllNodesInRel1(Node groupN,
			CrimenetRelationshipTypes memberof, String nodeType) {

		List<Node> nodes = new ArrayList<Node>();
		for (Relationship relationship : groupN.getRelationships()) {
			if (("" + relationship.getType()).equals("" + memberof)) {
				for (Node user : relationship.getNodes()) {
					for (String userProperty : user.getPropertyKeys()) {

						if ((userProperty).equals("Type")) {
							try {
								if (user.getProperty(userProperty).equals(
										nodeType)) {
									nodes.add(user);
								}
							} catch (NotFoundException nfe) {
								System.out.println(nfe.getLocalizedMessage());
							}
						}
					}
				}
			}
		}
		return nodes;
	}
	
	public static void main(String[] args) {
		ExecutionEngine engine = new ExecutionEngine( new EmbeddedGraphDatabase("/home/dsm8/Pictures/sampledb"));
		String query = Util.readFile("src/query.txt");
		ExecutionResult result = engine.execute( query);
		System.out.println( result );
	}
//		System.out.println("asd=12".split("=")[0]);}
//		GraphDatabaseService graphDB = new EmbeddedGraphDatabase(
//				"/home/dsm8/Documents/tmp/720/db/graphdb");
//
//		Node gNode = DBUtils.getNodeByName(graphDB, "damagelab", "Comm");
//
//		Iterable<Node> map1 = DBUtils.getAllNodesInRel(gNode,
//				CrimenetRelationshipTypes.MemberOf, "User");
//		// System.out.println(map1.size());
//		for (Node n1 : map1) {
//			System.out.println(n1.getProperty("Name"));
//		}
//	}

	public static List<Node> getNodesByName(GraphDatabaseService graphDB,
			Collection<String> groupList, String type) {
		List<Node> groupListReturn = new ArrayList<Node>();
		List<Node> itr = getAllNodeTypes(graphDB, "Comm");
		Logger.getLogger(DBUtils.class).info(itr);
		boolean found = false;
		for (Node user : itr) {
						String uName = "" + user.getProperty("Name");
						if (groupList.contains(uName)) {
							groupListReturn.add(user);
							if (groupListReturn.size() == groupList.size()) {
								found = true;
								break;
							}
						}
			if (found) {
				break;
			}
		}
		return groupListReturn;
	}

	public static void printUserinfluence(Node node) {
		// TODO Auto-generated method stub
		String uName1 = "" + node.getProperty("Name");
		for (String key : node.getPropertyKeys()){
			try {
				if (key.matches(CrimenetConstants.USER_INFLUENCE+".*")) {
					String uName = "" + node.getProperty(key);
					if (Double.parseDouble(uName) > 0) {
						Logger.getLogger(DBUtils.class).error(uName1 + "----USERINFO---->" + key + "---->"
								+ Double.parseDouble(uName));
					}
				}
			} catch (Exception e) {
				System.out.println(e.getLocalizedMessage());
			}
		}
	}

}